#!/usr/bin/env perl
use warnings;
use strict;

# while (<>) {
	# s/\t/\\t/g;
	# print;
	# print "\n";
# }

# print "Chrom\tGRCh37 Pos\tdbSNP ID\tCOSMIC ID\tRef\tVariant\tGene Name\tVariant Type\tTranscript ID\tCodon Change\tAA Change\tFiltered Coverage\tAllele Coverage\tAllele Frequency\tVariant Frequency\tP-Value\tsnpEff Effect\tsnpEff Impact\tFilter\tSIFT Score\tInterpro Domain\tUniProt\tPolyPhen Score\tCOSMIC Sample Count\tSomatic Mutation Assay\tVariant Clinical Significance\n";

# `cat title.txt line.1.txt`;

# $^I = ".bak";

while (<>) {
	chomp;
	my @depth = split /\t/;
	if (@depth > 1) {
		foreach my $i (0..$#depth-2) {
			printf "%.3f\t", $depth[$i]/$depth[$#depth];
		}
		printf "%.3f\n", $depth[-2]/$depth[$#depth];
	}else {
		my $p_value = 10**(-$_/10);
		if ($p_value < 0.00001) {
			$p_value = 0.00001;
		}
		printf "%.5f\n", $p_value;
	}
}

